package main;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import lombok.SneakyThrows;
import utils.SmallTool;

import java.util.List;
import java.util.Optional;

/**
 * @Author: gcr
 * @Date: 2022-3-9 7:35
 */
public class comparedoinew {
    @SneakyThrows
    public static void main(String[] args) {

        Db use = Db.use();

        SmallTool.printMemory();

        String server = "select * from pubmed_25600000_5wan";
        String newParse = "select * from pubmed_vip_extend_new";

        SmallTool.printMess("读表开始");

        List<Entity> entities = use.query(server);
        List<Entity> newParseList = use.query(newParse);
        SmallTool.printMemory();
        SmallTool.printMemory();
        SmallTool.printMess("读表结束");
        entities.parallelStream().forEach(entityServer -> {
            Integer pmidServer = entityServer.getInt("pmid");
            String doiServer = entityServer.getStr("doi");
//            SmallTool.printMess("开始比对+++pmid++" + pmidServer);

            Optional<Entity> pmid = newParseList.stream().filter(o -> o.getInt("pmid").equals(pmidServer)).findFirst();
            if (pmid.isPresent()) {
                Entity entityNew = pmid.get();
                if (entityNew != null) {
                    String doi = entityNew.getStr("doi");
                    if (doi == null && doiServer != null) {
                        SmallTool.printMessError("doi pmidServer+" + pmidServer + "+不同++++server++" + doiServer + "+++new的+++" + entityNew.getStr("doi"));

                    } else if (doi != null && doiServer == null) {
                        SmallTool.printMessError("doi pmidServer+" + pmidServer + "+不同++++server++" + doiServer + "+++new的+++" + entityNew.getStr("doi"));

                    } else if (doi == null && doiServer == null) {
//                    SmallTool.printMess("doi+++相同是 null");

                    } else {
                        if (doi.equals(doiServer)) {
//                        SmallTool.printMess("doi+++相同");
                        } else {
                            SmallTool.printMessError("doi pmidServer+" + pmidServer + "+不同++++server++" + doiServer + "+++new的+++" + entityNew.getStr("doi"));


                        }
                    }
                }
            }


        });


    }
}
